package com.example.usermanagement.listen;

import com.example.usermanagement.events.LiukaMessageApplicationEvent;
import com.example.usermanagement.liuka.model.FlowMessage;
import com.example.usermanagement.liuka.service.FlowMessageService;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

/**
 * @author yha
 * @ClassName
 * @description:TODO
 * @date 2024年09月12日
 * @version: 1.0.0
 */
@Service
public class LiukaMessageListen implements ApplicationListener<LiukaMessageApplicationEvent> {

    private FlowMessageService flowMessageService;

    @Override
    public void onApplicationEvent(LiukaMessageApplicationEvent event) {
        FlowMessage flowMessage = new FlowMessage();
        flowMessage.setMessage(event.getMessage());
        flowMessage.setPhone(event.getPhone());
        flowMessageService.save(flowMessage);
    }
}
